package com.fsm.demo.entity.excelbo;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.OnceAbsoluteMerge;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "合并单元格")
/**
 * @OnceAbsoluteMerge 指定从哪一行/列开始,哪一行/列结束,进行单元格合并
 * firstRowIndex 起始行索引,从0开始
 * lastRowIndex 结束行索引
 * firstColumnIndex 起始列索引,从0开始
 * lastColumnIndex 结束列索引
 */
// 例如: 第2-3行,2-3列进行合并
@OnceAbsoluteMerge(firstRowIndex = 1, lastRowIndex = 2, firstColumnIndex = 1, lastColumnIndex = 2)
public class Demo8Bo {

    // 每隔两行合并一次(竖着合并单元格)
//    @ContentLoopMerge(eachRow = 2)
    // 从此字段数据竖着每两行，横着每三行合并
//    @ContentLoopMerge(eachRow = 2, columnExtend = 3)
    @ExcelProperty(value = {"信息", "用户编号"}, index = 0)
    private Integer userId;

    @ExcelProperty(value = {"信息", "姓名"}, index = 1)
    private String userName;

    @ExcelProperty(value = {"信息", "性别"}, index = 2)
    private String gender;

    @ExcelProperty(value = {"其他", "工资"}, index = 3)
    @NumberFormat(value = "###.#") // 数字格式化,保留1位小数
    private Double salary;

    @ExcelProperty(value = {"其他", "入职时间"}, index = 4)
    @DateTimeFormat(value = "yyyy年MM月dd日 HH时mm分ss秒") // 日期格式化
    private Date hireDate;

}
